Skip to content

Handle log context with more than 100 metrics #42

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 21, 2020

Conversation

yaozhaoy
Copy link
Contributor

Issue #, if available:
#41

Description of changes:
Handle the case that there're more than 100 metrics in a metric context. The metrics would be split into multiple log event message in this case. There would be 100 metrics in the first several log message and the last one may have less than 100 log messages.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

public String serialize() throws JsonProcessingException {
return this.rootNode.serialize();
public List<String> serialize() throws JsonProcessingException {
if (rootNode.metrics().size() <= Constants.MAX_METRICS_PER_EVENT) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend adding a comment about what you’re doing here and why. Unfortunately, this bit of complexity exists because of constraints in the backend and it may not be clear to others what’s happening here.

aws.getCloudWatchMetrics().stream()
.flatMap(metricDirective -> metricDirective.getMetrics().values().stream())
.collect(Collectors.toList());
for (MetricDefinition metric : metrics) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We’re iterating over this collection twice. Can we do this in one pass?

@yaozhaoy yaozhaoy closed this Sep 21, 2020
@yaozhaoy yaozhaoy reopened this Sep 21, 2020
@yaozhaoy yaozhaoy merged commit fc0c624 into awslabs:master Sep 21, 2020
@yaozhaoy yaozhaoy deleted the metric_count_limit branch September 21, 2020 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants